package com.holly.unit.bpmn.designer.core.analysis;

import com.holly.unit.bpmn.designer.core.bpmn.BpmnModelActImpl;
import com.holly.unit.bpmn.designer.core.bpmn.BpmnModelFactory;
import com.holly.unit.bpmn.designer.model.ChildNode;
import org.activiti.bpmn.model.ServiceTask;

import java.util.ArrayList;
import java.util.List;

/**
 * 类描述: 抄送节点解析
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/12 13:45
 */
public class CsNodeAnalysis {

    private BpmnModelFactory factory;

    /***
     * 私有构造方法，禁止用户构造对象
     */
    private CsNodeAnalysis() {
        this.factory = new BpmnModelActImpl();
    }

    /***
     * 内部类持有单例实例，只有在被第一次被使用时才会被初始化
     */
    private static class CsNodeAnalysisHolder{
        /**
         * 静态实例变量保证全局唯一实例,被静态内部类持有
         * (静态内部类在外部类初始化不会被初始化，只有在第一次访问是才会被初始化)
         */
        private static CsNodeAnalysis instance = new CsNodeAnalysis();
    }

    public static CsNodeAnalysis getInstance() {
        return CsNodeAnalysisHolder.instance;
    }


    public List<ServiceTask> createServiceTask(List<ChildNode> csNodes) {
        List<ServiceTask> serviceTasks = new ArrayList<>();
        // TODO 借助ServiceTask
        serviceTasks.add(factory.createServiceTask("","",null));
        return serviceTasks;
    }

}
